package com.xxx.video.commen.configs;

import android.text.TextUtils;

import com.xxx.video.commen.utils.SPUtil;


public class UserManager {
    private static UserManager mUserManager = null;

    private UserManager() {
    }

    public static UserManager getInstance() {
        if (mUserManager == null) {
            synchronized (UserManager.class) {
                if (mUserManager == null) {
                    mUserManager = new UserManager();
                }
            }
        }
        return mUserManager;
    }

    /**
     * put token
     *
     * @param token token
     */
    public void putToken(String token) {
        SPUtil.putString(Constant.userToken, token);
    }

    /**
     * get Token
     *
     * @return token
     */
    public String getToken() {
        return SPUtil.getString(Constant.userToken, "");
    }

    /**
     * put userId
     *
     * @param userId userId
     */
    public void putUserId(String userId) {
        SPUtil.putString(Constant.userId, userId);
    }

    /**
     * get userId
     *
     * @return userId
     */
    public String getUserId() {
        return SPUtil.getString(Constant.userId, "");
    }
    /**
     * put avatar
     *
     * @param avatar avatar
     */
    public void putUserAvatar(String avatar) {
        SPUtil.putString(Constant.userAvatar, avatar);
    }

    /**
     * get avatar
     *
     * @return avatar
     */
    public String getUserAvatar() {
        return SPUtil.getString(Constant.userAvatar, "");
    }

    /**
     * put user name
     *
     * @param userName user name
     */
    public void putUserName(String userName) {
        SPUtil.putString(Constant.userName, userName);
    }

    /**
     * get user name
     *
     * @return user name
     */
    public String getUserName() {
        return SPUtil.getString(Constant.userName, "");
    }

    /**
     * put is agree agency
     *
     * @param isAgreeAgency is agree agency
     */
    public void setIsAgreeAgency(boolean isAgreeAgency) {
        SPUtil.putBoolean(Constant.agreeAgency, isAgreeAgency);
    }

    /**
     * get is agree agency
     *
     * @return get is agree agency
     */
    public boolean getIsAgreeAgency() {
        return SPUtil.getBoolean(Constant.agreeAgency, false);
    }
    /**
     * save register security info
     *
     * @param json json
     */
    public void putSaveSecurityOptionsBean(String json) {
        SPUtil.putString(Constant.registerSecurityOptionsBean, json);
    }

    /**
     * get save security options bean
     *
     * @return data
     */
    public String getSaveSecurityOptionsBean() {
        return SPUtil.getString(Constant.registerSecurityOptionsBean, "");
    }
    /**
     * is login
     *
     * @return is login
     */
    public boolean isLogin() {
        if (TextUtils.isEmpty(getToken())) {
            return false;
        } else {
            return true;
        }
    }

    /**
     * logout
     */
    public void logOut(){
        putToken("");
        putUserId("");
        putUserAvatar("");
        putUserName("");
    }
}
